﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace Adams.Admin.DataAccess.Membership
{
    public static class Common
    {
        public static Adams.Shared.Entities.Membership.MemberCollection GetMembersBySearch(string term)
        {
            var data = new Adams.Shared.Entities.Membership.MemberCollection();

            using (SqlDataReader dr = DB.RunDataReader(@"
SELECT * FROM Membership.Members WHERE FirstName LIKE '%" + term + @"%' OR LastName LIKE '%" + term + @"%' OR Email LIKE '%" + term + @"%'
", CommandType.Text))
            {
                while (dr.Read())
                {
                    var Member = new Adams.Shared.Entities.Membership.Member();
                    Member.ID = dr["MemberID"].DbInt();
                    Member.FirstName = dr["FirstName"].DbString();
                    Member.LastName = dr["LastName"].DbString();
                    Member.Email = dr["Email"].DbString();
                    Member.IsActive = dr["IsActive"].DbBool();
                    Member.IsLocked = dr["IsLocked"].DbBool();
                    data.Add(Member);
                }
            }

            return data;
        }
    }
}
